import { getBanners } from "@/api/banner";

export default {
	namespaced: true,
	state: {
		loading: false,
		datas: [],
	},
	mutations: {
		setLoading(state, payout) {
			state.loading = payout;
		},
		setDatas(state, payout) {
			state.datas = payout;
		},
	},
	actions: {
		async fetchGetBanner(ctx) {
			if (ctx.state.datas.length) {
				return;
			}
			ctx.commit("setLoading", true);
			const resp = await getBanners();
			ctx.commit("setDatas", resp);
			ctx.commit("setLoading", false);
		},
	},
};
